<?php
/**
 * 分库分表的自定义数据库路由配置
 * 
 * @license     http://www.phalapi.net/license GPL 协议
 * @link        http://www.phalapi.net/
 * @author: dogstar <chanzonghuang@gmail.com> 2015-02-09
 */

return array(
    /**
     * DB数据库服务器集群
     */
    'servers' => array(
        'driver' => 'mysql',
        'logicDel' => false,                 //是否打开逻辑删除
        'persistent' => false,               // 是否打开持久连接.
        'driverMode' => 'oci8',              // 系统支持pdo、adodb5的驱动，连接数据使用的类（DbAdo或DbPdo）,其中pdo目前mysql、pgsql、odbc，adodb5支持pdo/ado_mssql/odbc_mssql,odbc_oracle,db2/odbc_db2扩展mssql,mysql等
        'fetch' => PDO::FETCH_CLASS,
        'errorMode' => PDO::ERRMODE_WARNING,
        'connections' => array(
            'mysql' => array(
                'driver'    => 'mysql',
                'host'      => 'localhost',
                'database'  => 'heyi',
                'username'  => 'root',
                'password'  => '123',
                'port'      => '3306',
                'charset'   => 'utf8',
                'collation' => 'utf8_unicode_ci',
                'prefix'    => 'fc_',
                'strict'    => false,
                'engine'    => null,
            )
        )
    ),

    /**
     * Laravel DB数据库服务器集群
     */
    'laravel_db' => array(
        'default' => 'mysql',
        'fetch'     => PDO::FETCH_ASSOC,
        'connections' => array(
            'mysql' => array(
                'driver' => 'mysql',
                'host' => 'localhost',
                'port' => '3306',
                'database' => 'heyi',
                'username' => 'root',
                'password' => '123',
                'charset' => 'utf8',
                'collation' => 'utf8_unicode_ci',
                'prefix' => '',
            )
        )
    ),


    /**
     * 自定义路由表
     */
    'tables' => array(
        //通用路由
        '__default__' => array(
            'prefix' => '5kcrm_',
            'key' => 'id',
            'map' => array(
                array('db' => 'db_master'),
            ),
        ),
        'user' => array(
            'prefix' => '5kcrm_',
            'key' => 'user_id',
            'map' => array(
                array('db' => 'db_master'),
            ),
        ),

        /**
        'demo' => array(                                                //表名
            'prefix' => 'tbl_',                                         //表名前缀
            'key' => 'id',                                              //表主键名
            'map' => array(                                             //表路由配置
                array('db' => 'db_master'),                               //单表配置：array('db' => 服务器标记)
                array('start' => 0, 'end' => 2, 'db' => 'db_master'),     //分表配置：array('start' => 开始下标, 'end' => 结束下标, 'db' => 服务器标记)
            ),
        ),
         */
    ),
);
